import { useReactive } from "ahooks";

import appInfo from "../../publish/app.js";

const applicationModal = () => {
    let state = useReactive({
        applicationUuid: window.applicationUuid || appInfo.appUuid,
        applicationName: appInfo.appName,
        remoteApplication: {},
        remoteApplicationAuthorization: {},
        isExpire: false, // 是否过期
        isStop: false, // 是否暂停授权
        isAuth: false, // 是否功能授权
        startDate: null, // 授权开始日期
        endDate: null, // 授权结束日期
    });

    const setApplicationStateValue = (obj) => {
        for (let key in obj) {
            state[key] = obj[key];
        }
    };

    return {
        ...state,
        setApplicationStateValue,
    };
};

export default applicationModal;
